import requests from '@/utils/request'
//获取spu信息 /admin/product/{page}/{limit}  get
export const getSpuList=(page,limit,category3Id)=>requests({url:`/admin/product/${page}/${limit}`,method: 'GET',params:{category3Id}})

// 获取品牌列表 /admin/product/baseTrademark/getTrademarkList  get
export const reqTrademarkLiist=()=>requests({url:`/admin/product/baseTrademark/getTrademarkList`,method:'get'})

// 平台销售属性值  /admin/product/baseSaleAttrList  get 
export const reqSaleAttrList=()=>requests({url:`/admin/product/baseSaleAttrList`,method:'get'})

// 获取某一个类spu图片  /admin/product/spuImageList/{spuId}  get
export const reqImageList=(spuId)=>requests({url:`/admin/product/spuImageList/${spuId}`,method:'get'})

// 获取spu属性  /admin/product/getSpuById/{spuId}  get 
export const reqSpuInfo=(spuId)=>requests({url:`/admin/product/getSpuById/${spuId}`,method:'get'})





//新增或者修改SPU的函数
export const reqAddOrUpdateSpu = (spuInfo)=>{
    //修改
    if(spuInfo.id){
       return requests({url:'/admin/product/updateSpuInfo',data:spuInfo,method:'post'});
    }else{
        //添加
        return requests({url:'/admin/product/saveSpuInfo',data:spuInfo,method:'post'})
    }
}
//删除SPU
export const reqDeleteSpuById = (spuId)=>requests({url:`/admin/product/deleteSpu/${spuId}`,method:'delete'});

// 获取平台属性的接口  GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}

export const reqAttrList=(category1Id,category2Id,category3Id)=>requests.get(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)

//销售属性  GET /admin/product/spuSaleAttrList/{spuId}

export const reqSalesAttrList = (spuId)=>requests.get(`/admin/product/spuSaleAttrList/${spuId}`)


//图片列表  get  /admin/product/spuImageList/{spuId}

export const reqImagesList = (spuId)=>requests.get(`/admin/product/spuImageList/${spuId}`)



//保存SKU
///admin/product/saveSkuInfo  post 
export const reqSaveSkuInfo = (skuInfo)=>requests({url:'/admin/product/saveSkuInfo',data:skuInfo,method:'post'});


// 查看sku   GET /admin/product/findBySpuId/{spuId}
export  const reqSkuList = (spuId)=>requests({url:`/admin/product/findBySpuId/${spuId}`,method:'get'});